import React from 'react';
import {
  View,
  TouchableOpacity,
  Text,
} from 'react-native';

import BasePage from '../common/BasePage';
import TImage from '../../components/TImage';
import SizeUtils from '../../common/SizeUtils';
import Config from '../../config';
import JifenMallPointAction from '../../actions/jifenmall/JifenMallPointAction';

//award 协议
export default class JifenDuihuanResultPage extends BasePage {
  constructor(props) {
    super(props);

    this.state.jifenData = {point:{points:0}};
  }

  componentDidMount() {
    this._requestData();
  }

  componentWillUpdate(nextProps, nextState) {
    super.componentWillUpdate(nextProps, nextState);
    if(nextState.jifenData === null || nextState.jifenData === undefined) {
      nextState.jifenData = {point:{points:0}};
    }
  }

  _dealEnterPage() {
    super._dealEnterPage();
    this.state.jifenData = {point:{points:0}};
    this._requestData();
  }

  _requestData() {
    new JifenMallPointAction().call(this);
  }

  _dealRender() {
    return (
      <View style={{width:SizeUtils.getWindowSize().width,
          height:SizeUtils.getWindowSize().height}}>
        {this._renderContent()}
        {this._renderNavigationBar()}
      </View>
    )
  }

  _renderContent() {
    return (
      <View style={{paddingTop:Config.paddingTop,
          width:SizeUtils.getWindowSize().width, flexDirection:"column",
          alignItems:"center"}}>
          <TImage style={{width:300, height:300, marginTop:SizeUtils.translateDesignHeightToCode(213)}}
              resizeMode={"contain"}
              source={require("../../../resource/images/jifenmall/img_order.png")}/>
          <Text style={{color:"#db3132", fontSize:SizeUtils.translateFontSizeToCode(36),
              textAlign:"center", marginTop:SizeUtils.translateDesignHeightToCode(41)}}>
            订单提交成功!
          </Text>
          <Text style={{color:"#db3132", fontSize:SizeUtils.translateFontSizeToCode(26),
              textAlign:"center", marginTop:SizeUtils.translateDesignHeightToCode(20)}}>
            剩余积分:{this.state.jifenData ? this.state.jifenData.point.points : 0}
          </Text>
      </View>
    )
  }
}
